S1 = [
    [14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7],
    [0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8],
    [4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0],
    [15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13]
]

def sbox(n: int) -> int:
    n_bin = f'{n:06b}'
    row = int(n_bin[0] + n_bin[5], 2)
    col = int(n_bin[1:5], 2)

    return S1[row][col]

for i in range(0, 4):
    for j in range(0, 16):
        print(f"{sbox(i*16 + j):1x}", end="|")
    print()